/**
 * AccessLogServiceImpl.java
 * Created at 2016-5-5
 * Created by TangSanlin
 * Copyright (C) 2016 BROADTEXT SOFTWARE, All rights reserved.
 */
package com.broadtext.rms.system.service.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Service;

import com.broadtext.common.exp.DaoException;
import com.broadtext.common.exp.ServiceException;
import com.broadtext.common.repository.EntityDao;
import com.broadtext.common.service.impl.EntityServiceImpl;
import com.broadtext.rms.system.model.AccessLog;
import com.broadtext.rms.system.service.IAccessLogService;
import com.broadtext.rms.system.vo.LogExportModel;

/**
 * 
 * <p>
 * ClassName: AccessLogServiceImpl
 * </p>
 * <p>
 * Description: 日志务实现类
 * </p>
 * <p>
 * Author: TangSanlin
 * </p>
 * <p>
 * Date: 2016-5-17
 * </p>
 */
@Service("accessLogService")
public class AccessLogServiceImpl extends EntityServiceImpl<AccessLog> implements IAccessLogService {
    @Autowired
    @Qualifier("accessLogDao")
    public void setEntityDao(EntityDao<AccessLog> entityDao) {
        super.entityDao = entityDao;
    }
    
    
    /**
     * 
     * <p>Description: 获取导出列表</p>
     * @return 结果集
     * @throws DaoException 异常
     */
    @SuppressWarnings("unchecked")
    public List<LogExportModel> findExportLogList() throws DaoException {
        return this.entityDao.findByQuery("com.broadtext.rms.system.model.AccessLog.getExportLogList", null);
    }


    /** (non-Javadoc)
     * <p>Title: getUserIdByUsername</p>
     * <p>Description: </p>
     * @param username
     * @return
     * @throws ServiceException
     * @see com.broadtext.rms.system.service.IAccessLogService#getUserIdByUsername(java.lang.String)
     */
    @SuppressWarnings("unchecked")
    @Override
    public String getUserIdByUsername(String username) throws ServiceException {
        String userId = "";
        try {
            List<String> list= this.entityDao.findByProperty("com.broadtext.rms.system.model.AccessLog.getUserIdByUsername", username);
            if(list!=null&&list.size()>0){
                userId = list.get(0);
            }
        } catch (DaoException e) {
            e.printStackTrace();
            throw new ServiceException(e);
        }
        return userId;
    }
    
}
